import Vue from 'vue'
import Router from 'vue-router';
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style

NProgress.configure({showSpinner: false}) // NProgress Configuration

Vue.use(Router)

import writeBlogMd from './blog-center/write-blog-md'
import blogCreateCenter from './blog-center/blog-create-center'
import showAfterCreated from "@/router/blog-center/show-after-created";
import viewBlog from "@/router/blog-center/view-blog";
import userCenter from "@/router/user-center/user-center";

export const constantRoutes = [
    {
        path: '/login',
        component: () => import('@/views/login'),
        name: 'login'
    },
    {
        path: '/register',
        component: () => import('@/views/register'),
        name: 'register'
    },
    {
        path: '/',
        component: () => import('@/views/home/index'),
        name: 'index'
    },
    {
        path: '/oauth2',
        component: () => import('@/views/oauth2'),
        name: 'oauth2'
    }
]

export const blogRouter = [
    writeBlogMd,
    blogCreateCenter,
    showAfterCreated,
    viewBlog

]

export const userRouter = [
    userCenter
]

const dscnRouters = () => new Router({
    routes: [
        ...constantRoutes,
        ...blogRouter,
        ...userRouter,
        {
            path: '*',
            component: () => import('@/views/404/index.vue')
        },
    ],
    mode: 'history'
})

const router = dscnRouters()

export default router
